/**
 * Source file: ClaimantStatement_AutoLookups.ejs
 * Copyright (C) 2013 : Quantum Solutions
 * Id: $Id$
 * Date: $Date$
 */
 
// serverName is also defined in ConnectWebService (should be the same value)
//var serverName = "http://127.0.0.1:50057"; // rob VS
var serverName = "http://WIN-OV9FIKDJ4BV:88"; // Willie test
//var serverName = "http://suglifeabiqa01:88"; // Nedbank test

$(document).ready(function() {

/*
#ID   Type
f47  Title
f88  Suburb
f95  City
f105 Code
f141 Title
f156 Occupation
f172 Suburb
f180 City
f192 Code
*/
	// the field id is generated by Electric paper and should be changed to the apporiate value 
	// if the form is changed (fields added or deleted) this id could also change
	// the best way to locate the id is to right click on the field in firefox and select "Inspect Element"
	$( "#f47" ).autocomplete({
		source: function( request, response ) {
			$.ajax({
				url: serverName+"/ACBServiceProxy.svc/Autolookup", type: 'POST', dataType: 'json', contentType: 'application/json; charset="utf-8"',				
				data: '{"search":"' + request.term + '","type":"Title"}',
				success: function( msg ) {	response(msg.AutolookupResult);	}
			});
		}, minLength: 1 });			
	
	$( "#f88" ).autocomplete({
		source: function( request, response ) {
			$.ajax({
				url: serverName+"/ACBServiceProxy.svc/Autolookup", type: 'POST', dataType: 'json', contentType: 'application/json; charset="utf-8"',				
				data: '{"search":"' + request.term + '","type":"Suburb"}',
				success: function( msg ) {	response(msg.AutolookupResult);	}
			});
		}, minLength: 1 });			
	
	$( "#f95" ).autocomplete({
		source: function( request, response ) {
			$.ajax({
				url: serverName+"/ACBServiceProxy.svc/Autolookup", type: 'POST', dataType: 'json', contentType: 'application/json; charset="utf-8"',				
				data: '{"search":"' + request.term + '","type":"City"}',
				success: function( msg ) {	response(msg.AutolookupResult);	}
			});
		}, minLength: 1 });			

	$( "#f105" ).autocomplete({
		source: function( request, response ) {
			$.ajax({
				url: serverName+"/ACBServiceProxy.svc/Autolookup", type: 'POST', dataType: 'json', contentType: 'application/json; charset="utf-8"',				
				data: '{"search":"' + request.term + '","type":"Code"}',
				success: function( msg ) {	response(msg.AutolookupResult);	}
			});
		}, minLength: 1 });	

	$( "#f141" ).autocomplete({
		source: function( request, response ) {
			$.ajax({
				url: serverName+"/ACBServiceProxy.svc/Autolookup", type: 'POST', dataType: 'json', contentType: 'application/json; charset="utf-8"',				
				data: '{"search":"' + request.term + '","type":"Title"}',
				success: function( msg ) {	response(msg.AutolookupResult);	}
			});
		}, minLength: 1 });	

	$( "#f156" ).autocomplete({
		source: function( request, response ) {
			$.ajax({
				url: serverName+"/ACBServiceProxy.svc/Autolookup", type: 'POST', dataType: 'json', contentType: 'application/json; charset="utf-8"',				
				data: '{"search":"' + request.term + '","type":"Occupation"}',
				success: function( msg ) {	response(msg.AutolookupResult);	}
			});
		}, minLength: 1 });	

	$( "#f172" ).autocomplete({
		source: function( request, response ) {
			$.ajax({
				url: serverName+"/ACBServiceProxy.svc/Autolookup", type: 'POST', dataType: 'json', contentType: 'application/json; charset="utf-8"',				
				data: '{"search":"' + request.term + '","type":"Suburb"}',
				success: function( msg ) {	response(msg.AutolookupResult);	}
			});
		}, minLength: 1 });	

	$( "#f180" ).autocomplete({
		source: function( request, response ) {
			$.ajax({
				url: serverName+"/ACBServiceProxy.svc/Autolookup", type: 'POST', dataType: 'json', contentType: 'application/json; charset="utf-8"',				
				data: '{"search":"' + request.term + '","type":"City"}',
				success: function( msg ) {	response(msg.AutolookupResult);	}
			});
		}, minLength: 1 });	

	$( "#f192" ).autocomplete({
		source: function( request, response ) {
			$.ajax({
				url: serverName+"/ACBServiceProxy.svc/Autolookup", type: 'POST', dataType: 'json', contentType: 'application/json; charset="utf-8"',				
				data: '{"search":"' + request.term + '","type":"Code"}',
				success: function( msg ) {	response(msg.AutolookupResult);	}
			});
		}, minLength: 1 });	

		
});